package dk.itu.mobile.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * @author niebje
 *
 */
@XmlRootElement(name = "task")
public class Task implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@XmlAttribute
	public String id;
	@XmlAttribute
	public String name;

	public Date date;
	public Status status;
	public String description;
	public String attendants;
	transient private List <User> users;

	public Task() {
		//Empty constructor for marshalling
		users = new ArrayList<User>();
	}
	
	public Task(String name, String id, Date date, String description) {
		this.name = name;
		this.id = id;
		this.date = date;
		this.description = description;
		this.status = Status.NOT_EXECUTED;
	}
	
	public Task(String name, String id, Date date, String description, List <User> users) {
		this(name,id,date,description);
		this.users = users;
	}
	
	@XmlTransient
	public List<User> getUsers() {
		return users;
	}
	
	public void setUsers(List <User> users) {
		this.users = users;
		attendants = "";
		for (User item : users) {
			attendants += item.name +", ";
		}
	}
}
